package com.snopy.service.impl;

import com.snopy.mapper.CarouselMapper;
import com.snopy.pojo.Carousel;
import com.snopy.service.CarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * TODO
 *
 * @author snoopy
 * @date 2020/9/20 0020 10:56
 * @email 77912204@qq.com
 * @remark
 */
@Service
public class CarouselServiceImpl implements CarouselService {

    @Autowired
    private CarouselMapper carouselMapper;


    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public List<Carousel> queryAll(Integer isShow) {

        Example example = new Example(Carousel.class);
        Example.OrderBy sort = example.orderBy("sort");
        sort.asc();
        Example.Criteria criteria = example.createCriteria();

        criteria.andEqualTo("isShow",isShow);

        List<Carousel> carousels = carouselMapper.selectByExample(example);

        return carousels;
    }
}
